package com.duan.laugh.mp.listener;

import com.duan.laugh.mp.api.constans.MpConstants;
import com.duan.laugh.mp.service.IMpFansMsgResService;
import com.duan.laugh.msg.api.pojo.entity.MsgSend;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * <p>
 * 微信消息队列监听
 * </p>
 *
 * @author liutf
 * @since 2019/11/18
 */
@Component
@Slf4j
public class MpReceiveListener {
    @Autowired
    private IMpFansMsgResService mpFansMsgResService;

    /**
     * 监听微信消息
     *
     * @param
     */
    @RabbitListener(queues = MpConstants.MQ_QUEUE_MP)
    public void receiveUserMsg(MsgSend msgSend) {
        log.info("消息中心接收到微信发送请求：{}", msgSend);
        mpFansMsgResService.sendWxCustomerTemplateMsg(msgSend);
        log.info("给指定用户推送微信客服模版消息完毕");
    }
}
